/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package bea.cliente.gui.controllers;

import bea.cliente.core.Memory;
import bea.cliente.core.GuiManagerState;
import bea.cliente.gui.builders.AudioOptionsWindowBuilder;
import bea.cliente.gui.builders.GraphicsOptionsWindowBuilder;
import de.lessvoid.nifty.Nifty;
import de.lessvoid.nifty.elements.Element;
import de.lessvoid.nifty.screen.Screen;
import de.lessvoid.nifty.screen.ScreenController;

/**
 *
 * @author ivan
 */
public class LoginScreenController implements ScreenController {

    private GuiManagerState guiManager;
    private Nifty nifty;
    private Screen screen;
    private Element windowsContainer;
    private Element graphicsWindow;
    private Element audioWindow;
    private Element popupExit;

    @Override
    public void bind(Nifty nifty, Screen screen) {
        this.guiManager = Memory.get("guiManager");
        this.nifty = nifty;
        this.screen = screen;

        // busca o container das janelas
        windowsContainer = screen.findElementByName("loginLayerWindowsOptions");
    }

    @Override
    public void onStartScreen() {
    }

    @Override
    public void onEndScreen() {
    }

    public void onEnterButtonAction() {
        Element login = screen.findElementByName("txtLogin");
        Element password = screen.findElementByName("txtLogin");
        // verifica se esta vazio e notifica o usuario
        nifty.gotoScreen(GuiManagerState.MAIN_SCR);
    }

    public void onExitAction() {
    }

    public void buildGraphicsOptionsWindow() {
        if (!screen.findElementByName(GraphicsOptionsWindowBuilder.WINDOW_ID).isVisible()) {
            screen.findElementByName(GraphicsOptionsWindowBuilder.WINDOW_ID).setVisible(true);
        }
    }

    public void buildAudioOptionsWindow() {
        if (!screen.findElementByName(AudioOptionsWindowBuilder.WINDOW_ID).isVisible()) {
            screen.findElementByName(AudioOptionsWindowBuilder.WINDOW_ID).setVisible(true);
        }
    }
}
